package com.wiretap.interceptor;

import java.util.Map;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.wiretap.po.Administrator;
import com.wiretap.util.Constants;


/**
 * @author zzy
 * @catagory
 */
public class AuthInterceptor extends AbstractInterceptor {
	
	private static final long serialVersionUID = -6448836636785580845L;
	private static final Logger logger = Logger.getLogger(AuthInterceptor.class);

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		Map<String, Object> session = actionInvocation.getInvocationContext().getSession();
		if (session.get(Constants.SESSION_USER) == null || !(session.get(Constants.SESSION_USER) instanceof Administrator)) {
			logger.info("没有登陆!");
			return "global";
		}
		return actionInvocation.invoke();
	}
}
